class Solution {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<>() ;
        if(root == null)return list ;
        Stack<TreeNode> stack1 = new Stack<>() ;
        Stack<TreeNode> stack2 = new Stack<>() ;
        stack1.push(root);
        while(!stack1.empty()){
          TreeNode cur = stack1.pop() ;
          stack2.push(cur);
          if(cur.left != null){
            stack1.push(cur.left);
          }
          if(cur.right != null){
            stack1.push(cur.right);
          }
        }
        while(!stack2.empty()){
         TreeNode cur = stack2.pop() ;
         list.add(cur.val);
        }
 return list ;
    }
}